ElasticSearch DSL 语句
ES 的 Restful 语法
ES 几种常见的请求方式,与我们的传统的 Restful 有区别
# get请求(获取数据)
http://ip:port/index # 查询 es 的 index
http://ip:port/index/type/doc_id # 根据文档 id 查询指定文档的信息
# post请求
http://ip:port/index/type/_search # 查询文档,可以在请求体中添加 json 字符串的内容,代表查询条件
http://ip:port/index/type/doc_id/_update # 修改文档 ,在请求体中指定 json 字符串,代表修改条件
# put请求
http://ip:port/index # 创建索引,请求体中指定索引的信息
http://ip:port/index/type_mappings # 创建索引,然后指定索引存储文档的属性
# delete请求
http://ip:port/index # 删除索引(删库跑路~)
http://ip:port/index/type/doc_id # 删除指定的文档
field 的类型
前面说了 ES 的 field 和数据库的字段类似,所以它也有类型之分
字符串类型
text # 最常用,一般用于全文检索,会给 field 分词
keyword # 不会给 field 进行分词(就是关键字,例如地名,人名,手机号之类的)
数值类型
long
integer
short
byte
double
float
half_float # 精度比 float 小一半,float 是 32 位,这个是 16 位
scaled_float # 根据 long 类型的结果和你指定的 secled 来表达浮点类型:long:123 ,secled:100,结果:1.23
时间类型
date # 可以指定具体的格式 "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
布尔类型
boolean # false true